<?php
if(isset($_REQUEST['action']) && $_REQUEST['action']=='list'){
	if(!isset($_SESSION['sid'])) exit('{"status":"fail","msg":"请先登录后再操作","code":0}');
	
	include_once '/var/www/html/new/com.inc.php';
	
	$pageSize    = $_REQUEST['pageSize'] ? $_REQUEST["pageSize"]:10;
	$currentPage = $_REQUEST["currentPage"] ? $_REQUEST["currentPage"]:1;
	$pStart      = ($currentPage-1) * $pageSize;
	
	$dname = isset($_REQUEST['dname']) ? addslashes(rtrim($_REQUEST['dname'])):'';

	$where = "where t.seller_nick<>''";
	if($_REQUEST['status']==1) $where.=' and t.status=1';
	if($_REQUEST['status']==2) $where.=' and t.status=0';
	if($dname) $where.= " and m.dname like '%$dname%' ";

	$malist = array();
	$sql = "select t.id2 as mid,t.status,t.seller_nick,t.id as tid,t.createtime,m.account,m.mobile,m.dname from pft_tb_bind t left join pft_member m ON t.id2=m.id $where order by t.createtime desc limit $pStart,$pageSize";
	$GLOBALS['le']->query($sql);
	while($row = $GLOBALS['le']->fetch_assoc()) $malist[] = $row;

	$sql = "select count(t.id) as c from pft_tb_bind t left join pft_member m ON t.id2=m.id $where";
	$GLOBALS['le']->query($sql);
	$GLOBALS['le']->fetch_assoc();
	$total = $GLOBALS['le']->f('c');

	$GLOBALS['le']->close();
	$response = array('status'=>'success', 'list'=>$malist, 'pageSize'=>$pageSize, 'currentPage'=>$currentPage, 'total'=>$total, 'totalPage'=>ceil(($total/$pageSize)));
	exit(json_encode($response));
}


include_once("/var/www/html/new/d/common/header.html");
include_once("/var/www/html/new/d/common/left.html");


if($_SESSION['sid']!=1) exit('无权限操作');
include_once("/var/www/html/new/d/tpl/new_tpl/newTao/newTaoManage.html");
include_once ("/var/www/html/new/d/common/footer.html");
